﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddOrEdit.aspx.cs" Inherits="admin_Modules_Location_AddOrEdit" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="/admin/resources/css/base.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        .custom-trigger { background-image: url(/files/images/custom-trigger.gif) !important; }
    </style>
    <script src="/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/ckfinder.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/config.js" type="text/javascript"></script>
    <script src="/plugins/ckeditor/config.js" type="text/javascript"></script>
    <script src="/admin/resources/js/base.js" type="text/javascript"></script>
    <script type="text/javascript">

        //FCKEditor Js API
        var getFckText = function () {
            return CKEDITOR.instances.fckHtmlEditor.getData();
        }

        function BrowseServer() {
            // You can use the "CKFinder" class to render CKFinder in a page:
            var finder = new CKFinder();
            finder.basePath = '/plugins/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
            finder.selectActionFunction = SetFileField;
            finder.popup();
        }

        // This is a sample function which is called when a file is selected in CKFinder.
        function SetFileField(fileUrl) {
            triggerFilm.setValue(fileUrl);
            // document.getElementById('xFilePath').value = fileUrl;
        }


        function loadEditor() {
            var oFCKeditor = CKEDITOR.replace('fckHtmlEditor', {
                customConfig: '/plugins/ckeditor/config.js',
                filebrowserBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserImageBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserFlashBrowseUrl: '/plugins/ckfinder/ckfinder.html?type=Flash',
                filebrowserUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files',
                filebrowserImageUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images',
                filebrowserFlashUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash'

            });

            oFCKeditor.BasePath = '/plugins/ckeditor/';
            oFCKeditor.Width = '680px';
            oFCKeditor.Skin = 'v2';
            oFCKeditor.Height = '250px';
            //CKFinder.setupCKEditor(oFCKeditor, { basePath: '/ckfinder/', rememberLastFolder: false });
        }

        function setHtml(html) {
            return CKEDITOR.instances.fckHtmlEditor.setData(html);
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <ext:ResourceManager ID="ScriptManager2" runat="server">
            <Listeners>
                <DocumentReady Handler="loadEditor();" />
            </Listeners>
        </ext:ResourceManager>
        <ext:Viewport ID="wdAddOrEditImageCategory" runat="server" Layout="BorderLayout">
            <Items>
                <ext:Panel Region="Center" BodyStyle="backgound-color:#fff;" BodyBorder="true" Layout="Fit">
                    <TopBar>
                        <ext:Toolbar ID="Toolbar2" runat="server">
                            <Items>
                                <ext:Button Icon="Disk" Text="Cập nhật">
                                    <DirectEvents>
                                        <Click OnEvent="AddOrEdit" Before="valid = #{StatusForm2}.getForm().isValid(); if(valid){ Ext.Msg.wait('Đang cập nhật dữ liêu...', 'Saving'); } return valid;">
                                            <ExtraParams>
                                                <ext:Parameter Name="fckParameter" Mode="Raw" Value="getFckText()" />

                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Items>
                        <ext:FormPanel ID="StatusForm2" BodyBorder="false" Header="false" runat="server"
                            LabelWidth="120" BodyStyle="padding:5px">
                            <Items>
                                <ext:TextField runat="server" MaxLength="200" ID="txtName" FieldLabel="Tên"
                                    Width="260">
                                </ext:TextField>
                                <ext:TextArea ID="fckHtmlEditor" Name="fckHtmlEditor" runat="server" FieldLabel="Nội dung">
                                </ext:TextArea>
                                <ext:TextArea runat="server" ID="txtMaps" FieldLabel="Maps">
                                </ext:TextArea>
                            </Items>
                        </ext:FormPanel>
                    </Items>
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </form>
</body>
</html>
